﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Demo
{
    public partial class TeaAddStuList : System.Web.UI.Page
    {

        string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DataConnectionString3"].ConnectionString;

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string SequenceNumber = this.TextBox1.Text;                //得到登陆帐号
            string Number = this.TextBox2.Text;
            string Name = this.TextBox3.Text;
            string Class = this.TextBox4.Text;
            string Password = this.TextBox5.Text;
            string TeacherID = this.TextBox6.Text;
            //第1步 . 建立数据连接对象
            SqlConnection con = new SqlConnection();
            con.ConnectionString = connectionString;
            con.Open();                               //打开数据库连接
            //2.操作对象
            string sqlSelect = "insert into StudentList(SequenceNumber,Number,Name,Class,Password,TeacherID)values('" + SequenceNumber + "','" + Number + "','" + Name + "','" + Class + "','" + Password + "','" + TeacherID + "')";
            SqlCommand cmd = new SqlCommand(sqlSelect, con);     //创建SqlCommand对象
            cmd.ExecuteNonQuery();
            Response.Redirect("ShowStu.aspx");
            con.Close();
        }
    }
}